package hu;

import java.util.*;

public class hu33 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] ip = sc.nextLine().split("\\.");
        long num = Long.parseLong(sc.nextLine());
        long ipToNum = 0;
        long temp = 1;
        for (int i = ip.length - 1; i >= 0; i--) {
            int t = Integer.parseInt(ip[i]);
            ipToNum += t * temp;
            temp *= Math.pow(2,8);
        }
        String numToIp = "";
        long p = 0;
        for (int i = 0; i < ip.length; i++) {
            p = (long) (num % Math.pow(2, 8));
            if(i != 0)
                numToIp = p + "." + numToIp;
            else
                numToIp = p + numToIp;
            num = (long) (num / Math.pow(2,8));
        }
        System.out.println(ipToNum);
        System.out.println(numToIp);
    }
}
